#include <iostream>

using namespace std;

class Singleton
{
    public:
        static Singleton* Instance();
        void setValue(int val) { value = val; }
        int getValue() { return value; }
    protected:
        Singleton() {}
    private:
        static Singleton *_instance;
        int value;
};

Singleton* Singleton::_instance = NULL;

Singleton* Singleton::Instance()
{
    if (_instance == NULL)
    {
        _instance = new Singleton();
    }

    return _instance;
}

int main()
{
    Singleton * a = Singleton::Instance();
    Singleton * b = Singleton::Instance();

    a->setValue(10);
    cout << b->getValue() << endl;
    return 0;
}

